package com.egao.orderB.controller;

import com.egao.common.core.annotation.ApiPageParam;
import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.*;
import com.egao.common.core.annotation.OperLog;
import com.egao.orderB.entity.OceanFee;
import com.egao.orderB.service.OceanFeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.ui.Model;


/**
 *
 * 海运费用
 * @author : Doman
 * @date : 2020-12-04 16:07:56
 * @version ：1.0
 */

@Api(tags = "海运费用")
@RestController
@RequestMapping("/api/orderB/oceanFee")
public class OceanFeeController extends BaseController {

	@Autowired
	private OceanFeeService oceanFeeService;

	/**
	 * 分页查询列表
	 */
	@PreAuthorize("hasAuthority('orderB:oceanFee:list')")
    @OperLog(value = "海运费用", desc = "分页查询")
    @ApiOperation(value ="分页查询海运费用",notes = "" +
            "id:id\n" +
            "organizationId:公司id\n" +
            "oceanId:订单id\n" +
            "type:类型\n" +
            "feeName:费用名称\n" +
            "price:金额\n" +
            "standard:标准\n" +
            "feeState:费用状态:未确认,已确认\n" +
            "feePerson:确认人\n" +
            "feeTime:确认时间\n" +
            "fobject:费用对象 货代,司机,码头\n" +
            "invoiceid:抬头id\n" +
            "invoicename:抬头\n" +
            "driverName:司机名称\n" +
            "invoicestate:是否开票:开票1 不开票0  \n" +
            "currency:币种\n" +
            "exchangeRate:汇率\n" +
            "remark:备注\n" +
            "createTime:创建时间\n" +
            "createUser:创建人\n" +
            "updateTime:更新时间\n" +
            "updateUser:更新人\n" +
            "deleted:del(0正常 1删除)\n" +
            "",httpMethod = "POST")
    @ApiPageParam
    @PostMapping("/list")
    public JsonResult page(PageResult2<T> page, OceanFee oceanFee) throws Exception{
        return oceanFeeService.list(page, oceanFee, getLoginUser());
    }

    /**
     * 查询全部海运费用
     */
    @PreAuthorize("hasAuthority('orderB:oceanFee:list')")
    @OperLog(value = "海运费用", desc = "查询全部")
    @ApiOperation("查询全部海运费用")
    @PostMapping("/listAll")
    public JsonResult list(OceanFee oceanFee){
        return oceanFeeService.list(oceanFee, getLoginUser());
    }

    /**
     * 根据id查询海运费用
     */
    @PreAuthorize("hasAuthority('orderB:oceanFee:list')")
    @OperLog(value = "海运费用", desc = "根据id查询")
    @ApiOperation("根据id查询海运费用")
    @PostMapping("/get")
    public JsonResult get(OceanFee oceanFee) {
        return oceanFeeService.getById(oceanFee);
		// 使用关联查询
        //PageParam<oceanFee> pageParam = new PageParam<>();
		//pageParam.put("id", id);
        //List<oceanFee> records = oceanFeeService.listAll(pageParam.getNoPageParam());
        //return JsonResult.ok().setData(pageParam.getOne(records));
    }


    /**
     * 添加海运费用
     */
    @PreAuthorize("hasAuthority('orderB:oceanFee:save')")
    @OperLog(value = "海运费用", desc = "添加", param = false, result = true)
    @ApiOperation(value ="添加海运费用",notes = "" +
            "oceanId:订单id\n" +
            "type:类型\n" +
            "feeName:费用名称\n" +
            "price:金额\n" +
            "standard:标准\n" +
            "feeState:费用状态:未确认,已确认\n" +
            "feePerson:确认人\n" +
            "feeTime:确认时间\n" +
            "fobject:费用对象 货代,司机,码头\n" +
            "invoiceid:抬头id\n" +
            "invoicename:抬头\n" +
            "driverName:司机名称\n" +
            "invoicestate:是否开票:开票1 不开票0  \n" +
            "currency:币种\n" +
            "exchangeRate:汇率\n" +
            "remark:备注\n" +
            "",httpMethod = "POST")
    @PostMapping("/save")
    public JsonResult save(Model model, OceanFee oceanFee) {
        return oceanFeeService.save(oceanFee, getLoginUser());
    }

    /**
     * 修改海运费用
     */

    @PreAuthorize("hasAuthority('orderB:oceanFee:update')")
    @OperLog(value = "海运费用", desc = "修改", param = false, result = true)
    @ApiOperation(value ="修改海运费用",notes = "" +
            "id:id\n" +
            "type:类型\n" +
            "feeName:费用名称\n" +
            "price:金额\n" +
            "standard:标准\n" +
            "feeState:费用状态:未确认,已确认\n" +
            "feePerson:确认人\n" +
            "feeTime:确认时间\n" +
            "fobject:费用对象 货代,司机,码头\n" +
            "invoiceid:抬头id\n" +
            "invoicename:抬头\n" +
            "driverName:司机名称\n" +
            "invoicestate:是否开票:开票1 不开票0  \n" +
            "currency:币种\n" +
            "exchangeRate:汇率\n" +
            "remark:备注\n" +
            "",httpMethod = "POST")
    @PostMapping("/update")
    public JsonResult update(Model model, OceanFee oceanFee) {
        return oceanFeeService.update(oceanFee, getLoginUser());
    }

    /**
     * 删除海运费用
     */
    @PreAuthorize("hasAuthority('orderB:oceanFee:remove')")
    @OperLog(value = "海运费用", desc = "删除", result = true)
    @ApiOperation("删除海运费用")
    @PostMapping("/remove")
    public JsonResult remove(OceanFee oceanFee ) {
        return oceanFeeService.remove(oceanFee, getLoginUser());
    }

    /**
     * 批量添加海运费用
     */
    /**@RequiresPermissions("orderB:oceanFee:save")
    @OperLog(value = "海运费用", desc = "批量添加", param = false, result = true)
    @ResponseBody
    @PostMapping("/saveBatch")
    public JsonResult saveBatch(@RequestBody List<OceanFee> list) {
        if (oceanFeeService.saveBatch(list)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }*/

    /**
     * 批量修改海运费用
     */
    /**@RequiresPermissions("orderB:oceanFee:update")
    @OperLog(value = "海运费用", desc = "批量修改", result = true)
    @ResponseBody
    @PostMapping("/updateBatch")
    public JsonResult updateBatch(@RequestBody BatchParam<OceanFee> batchParam) {
        if (batchParam.update(oceanFeeService, "")) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }*/

    /**
     * 批量删除海运费用
     */
    /**@RequiresPermissions("orderB:oceanFee:remove")
    @OperLog(value = "海运费用", desc = "批量删除", result = true)
    @ResponseBody
    @PostMapping("/removeBatch")
    public JsonResult removeBatch(@RequestBody List<Integer> ids) {
        if (oceanFeeService.removeByIds(ids)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }*/

}
